package com.example.day20_zhongji.model;

import com.example.day20_zhongji.base.BaseModel;
import com.example.day20_zhongji.base.BaseObserver;
import com.example.day20_zhongji.bean.ArticleBean;
import com.example.day20_zhongji.not.ApiService;
import com.example.day20_zhongji.not.HttpUlist;
import com.example.day20_zhongji.not.RxUlist;

import io.reactivex.Observable;

public class AritcleModel extends BaseModel {
    public void aritcleModel(AritcleCallBack callBack){
        ApiService apiServer = new HttpUlist().getApiServer(ApiService.url, ApiService.class);
        Observable<ArticleBean> getarticle = apiServer.getarticle();
        getarticle.compose(RxUlist.ReObservableTransformer())
                .subscribe(new BaseObserver<ArticleBean>(this) {
                    @Override
                    protected void onSuccess(ArticleBean articleBean) {
                        callBack.onSuccess(articleBean);
                    }

                    @Override
                    protected void onFali(String message) {
                        callBack.onFali(message);
                    }
                });
    }
}